package com.beiyou.service;

import cn.hutool.core.bean.BeanUtil;
import com.beiyou.dao.UserMapper;
import com.beiyou.dto.UserDto;
import com.beiyou.dto.UserDtoQuery;
import com.beiyou.entity.UserEntity;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import java.util.List;

/**
 * @author wzby
 * @Date: 2022/10/17 11:00
 */
@Service
public class UserService {

    @Autowired
    private UserMapper userMapper;

    public List<UserDto> select(UserDtoQuery userDtoQuery) {
        List<UserEntity> entityList = userMapper.select(userDtoQuery);
        return BeanUtil.copyToList(entityList, UserDto.class);
    }

    public  Integer insert(UserDto userDto){
        UserEntity userEntity = BeanUtil.copyProperties(userDto, UserEntity.class);
        return userMapper.insert(userEntity);
    }
}
